//
//  HomeViewController.m
//  FangXinLang
//
//  Created by AJY on 16/9/18.
//  Copyright © 2016年 AJY. All rights reserved.
//

#import "HomeViewController.h"

#import "BYConditionBar.h"
#import "SelectionButton.h"
#import "BYSelectionDetails.h"
#import "BYSelectNewBar.h"
#import "PushTableViewController.h"
#import "UIBarButtonItem+BarButtonItem.h"
#import "FTableViewController.h"
#import "SearchViewController.h"
#define ScreenW [UIScreen mainScreen].bounds.size.width
#define ScreenH [UIScreen mainScreen].bounds.size.height
@interface HomeViewController ()

@property(nonatomic,strong)UIScrollView *scroll;
@property(nonatomic,strong)FTableViewController *ftable;
@end

@implementation HomeViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets=NO;
    [self.navigationController.navigationBar setTranslucent:NO];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    [self addfootscroller];
    [self makeContent];
    [self additem];
    [self addfootscroller];
    
    [self addChildViewController];
}
//创建自控制器
-(void)addChildViewController{
    for(int i=0;i<5;i++)
    {
       _ftable=[[FTableViewController alloc]init];
        [self addChildViewController:_ftable];
    }
}
-(void)addfootscroller{
    self.scroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 60, ScreenW, ScreenH-60)];
    self.scroll.backgroundColor=[UIColor purpleColor];
    [self.view addSubview:self.scroll];
    [self.scroll addSubview:_ftable.view];
}
-(void)makeContent
{
        //添加scroller
    BYConditionBar *conditionBar = [[BYConditionBar alloc] initWithFrame:CGRectMake(0, 0, ScreenW-40, 30)];
    [self.view addSubview:conditionBar];
        //添加view(跳转到页的头标题)
    BYSelectNewBar *selection_newBar = [[BYSelectNewBar alloc] initWithFrame:CGRectMake(0, 30, conditionBar.frame.size.width, 30)];
    [self.view addSubview:selection_newBar];
    
        //添加按钮(跳转)
    SelectionButton *arrow = [[SelectionButton alloc] initWithFrame:CGRectMake(ScreenW-40, 0, 40, 30)];
        arrow.Newbar = selection_newBar;
    [self.view addSubview:arrow];
    arrow.backgroundColor=[UIColor whiteColor];
}

-(void)click{
    
}
-(void)additem{
    
    
    UIButton *b=[UIButton buttonWithType:UIButtonTypeCustom];
    UIBarButtonItem *btn=[UIBarButtonItem barButtonItemWith:b andTarget:nil andAction:nil andImage:@"navi_logo" andImageHeight:@"navi_logo"];
    self.navigationItem.leftBarButtonItem = btn;
    //右边推送按钮
    
    UIButton *bt=[UIButton buttonWithType:UIButtonTypeCustom];
    UIBarButtonItem *itemR1=[UIBarButtonItem barButtonItemWith:bt andTarget:self andAction:@selector(rightBtn1) andImage:@"navi_box_icon_hl@2x 2" andImageHeight:@"navi_box_icon_hl"];
    //右边🔍按钮
    
    UIButton *bt1=[UIButton buttonWithType:UIButtonTypeCustom];
    UIBarButtonItem *itemR2=[UIBarButtonItem barButtonItemWith:bt1 andTarget:self andAction:@selector(rightBtn2) andImage:@"navi_search_icon_hl@2x" andImageHeight:@"navi_search_icon_hl@3x"];
    self.navigationItem.rightBarButtonItems = @[itemR2,itemR1];
    
    
}
//今日推送的跳转
-(void)rightBtn1{
    PushTableViewController *push=[[PushTableViewController alloc]init];
    [self.navigationController pushViewController:push animated:YES];
    
}
-(void)rightBtn2{
    SearchViewController * login = [[SearchViewController alloc]init];
    login.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:login animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
